package com.gxc.validation;

import com.gxc.service.HelloService;

import javax.annotation.Resource;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.ArrayList;
import java.util.List;

/**
 * @author GongXincheng
 * @since 2019-10-12 17:43
 */
public class MyConstraintValidator implements ConstraintValidator<MyConstraint, Object> {

    @Resource
    private HelloService helloService;

    @Override
    public boolean isValid(Object o, ConstraintValidatorContext constraintValidatorContext) {
        System.out.println(helloService.hello());
        if (o != null) {
            System.out.println(o.toString());
        }
        return true;
    }

    @Override
    public void initialize(MyConstraint constraintAnnotation) {
        System.out.println("init ---- MyConstraint");
    }

}
